﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PotbsData;
using System.Xml;
using System.IO;

namespace potbs_ems
{
    public partial class Testing : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnTest_Click(object sender, EventArgs e)
        {
            /*
            XmlDataDocument xdata = new XmlDataDocument();

            xdata.DataSet.ReadXmlSchema(MapPath("~/bin/Resources/GetServerStatus().xsd"));
            xdata.Load(XmlClient.GetServerStatus().CreateReader());
            */

            DataPump.LandmarkStatus(MapPath("~/bin/Resources/GetLandmarkStatus(Server).xsd"));

            //xdata.Load(XmlClient.GetLandmarkStatus("blackbeard", "CatIsl").CreateReader());

            //display Dataset
            //displayXmlDataset(xdata, true);

            //Pump XmlDataDocument to SQL
            //DataPump.PumpBulkServerStatus(xdata);
            //DataPump.PumpStatics(xdata);

            //xdata.DataSet.ReadXmlSchema(MapPath("~/bin/Resources/GetStatics().xsd"));
            //xdata.Load(XmlClient.GetStatics().CreateReader());
            //displayXmlDataset(xdata, false);

        }

        protected void displayXmlDataset(XmlDataDocument xdata, bool displayData)
        {
            foreach (System.Data.DataTable tbl in xdata.DataSet.Tables)
            {
                txtResult.Text += string.Format("{0}\r\n", tbl.TableName);
                foreach (System.Data.DataColumn col in tbl.Columns)
                {
                    txtResult.Text += string.Format("\t{0}\r\n", col.ColumnName);
                    if (displayData)
                    {
                        foreach (System.Data.DataRow row in tbl.Rows)
                        {
                            txtResult.Text += string.Format("\t\t{0}\r\n", row[col].ToString());
                        }
                    }
                }
            }
        }
    }
}
